<?php
/*
 * Erstellt neue Ligen..
 */
require_once('../Database/Database.php');
require_once('../help_funcs.php');

echo 'Creating table....<br />';

$db          = new Database();
$db->Connect();

$league_name = $_POST['league_name'];
$shortcut    = MakeShortcut($league_name, $_POST['shortcut']);
$game        = $_POST['select_game'];
$columns     = array('ID_League', 'Name'      , 'Shortcut', 'Game');
$values      = array('auto'     , 's'         , 's'       , 's');

if($db->CreateTable('Leagues', $columns, $values))
{
    echo 'Inserting values.....<br />';

    $columns     = array('Name', 'Shortcut', 'Game');
    $values      = array($league_name, $shortcut, $game);

    // Werte einfügen...
    if($db->Insert('Leagues', $columns, $values))
    {
        echo 'Values inserted.<br />';
    }
    else
    {
        echo 'Error inserting the values.<br />';
    }
}
else
{
    echo 'Could not create league table.';
}
$db->Disconnect();
$back_url = '../index.php?page=all_leagues';
?>
<div id="back">
        <?php echo '<a href="' . $back_url . '">Mainmenu</a>'; ?>
</div>